package com.zch;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.base.mobile.MobException;
import com.base.util.DateUtil;

import com.h5.action.H5BaseController;
import com.zch.dao.model.Ability;
import com.zch.dao.model.AbilityExample;
import com.zch.dao.model.ApplyProject;
import com.zch.dao.model.ApplyProjectExample;
import com.zch.dao.model.Bank;
import com.zch.dao.model.BankExample;
import com.zch.dao.model.MyActivityExample;
import com.zch.dao.model.ServiceOrganization;
import com.zch.dao.model.ServiceOrganizationExample;
import com.zch.dao.model.Zhiku;
import com.zch.dao.model.ZhikuExample;
import com.zch.daoEx.model.ActivitymessageEx;
import com.zch.daoEx.model.ApplyProjectEx;
import com.zch.daoEx.model.CollegemessageEx;
import com.zch.daoEx.model.MyActivityEx;
import com.zch.daoEx.model.PolicyEx;
import com.zch.daoEx.model.PrincipalEx;
import com.zch.daoEx.model.TechnologymessageEx;
import com.zch.daoEx.model.XqmessageEx;
import com.zch.daoEx.model.ZaitiEx;
import com.zch.daoEx.model.ZhikuEx;
import com.zch.daoEx.model.ZxMessageEx;
import com.zch.mobile.MZchError;
import com.zch.service.AbilityService;
import com.zch.service.ActivitymessageService;
import com.zch.service.ApplyProjectService;
import com.zch.service.BankService;
import com.zch.service.CollegemessageService;
import com.zch.service.MyActivityService;
import com.zch.service.PolicyService;
import com.zch.service.PrincipalService;
import com.zch.service.ServiceOrganizationService;
import com.zch.service.TechnologymessageService;
import com.zch.service.XqmessageService;
import com.zch.service.ZaitiService;
import com.zch.service.ZhikuService;
import com.zch.service.ZxMessageService;


@RequestMapping("share")
@Controller
public class h5action extends H5BaseController{
    @Autowired
    private ActivitymessageService activitymessageService;
    @Autowired
    private MyActivityService myActivityService;
    @Autowired
    private ZaitiService zaitiService;
    @Autowired
    private ZxMessageService zxMessageService;
    @Autowired
    private PrincipalService principalService;
    @Autowired
    private CollegemessageService collegemessageService;
    @Autowired
    private TechnologymessageService technologymessageService;
    @Autowired
    private XqmessageService xqmessageService;
    @Autowired
    private PolicyService policyService;
    @Autowired
    private ServiceOrganizationService serviceOrganizationService;
    @Autowired
    private BankService bankService;
    @Autowired
    private ApplyProjectService applyProjectService;
    @Autowired
    private AbilityService abilityService;
    @Autowired
    private ZhikuService zhikuService;
    /**
     * 活动详情分享
     */
    @RequestMapping("/getAct")
    public String  getAct(String id,ModelMap map) throws Exception{
        Map<String ,Object> maps = new HashMap<String, Object>();
        maps.put("id", id);
        ActivitymessageEx data = activitymessageService.selectDetail(maps);
        if(data==null){
            throw new MobException(MZchError.CONTENT_NOT_EXIST);
        }
        data.setTime(DateUtil.dateToStr(data.getActivityTime()));
        map.put("data", data);
     return BASE_PATH+"/actshare";
    }
    
    /**
     * 载体详情分享
     * @param id
     * @param map
     * @return
     * @throws Exception
     */
    @RequestMapping("/getZaiti")
    public String getZaiti(String id, ModelMap map)throws Exception{
        Map<String ,Object> maps = new HashMap<String ,Object>();
        maps.put("id", id);
        ZaitiEx data = zaitiService.selectAppDetailLists(maps);
        if(data==null){
            throw new MobException(MZchError.CONTENT_NOT_EXIST);
        }
        map.put("data", data);
     return BASE_PATH+"/zaitishare";
    }
    
    /**
     * 资讯详情分享
     * @param id
     * @param map
     * @return
     * @throws Exception
     */
    @RequestMapping("/getZixun")
    public String getzixun(String id, ModelMap map)throws Exception{
        Map<String ,Object> maps = new HashMap<String ,Object>();
        maps.put("id", id);
        ZxMessageEx data = zxMessageService.selectAppDetailList(maps);
        if(data==null){
            throw new MobException(MZchError.CONTENT_NOT_EXIST);
        }
        map.put("data", data);
     return BASE_PATH+"/zixunshare";
    }
    
    /**
     * 资本详情分享
     * @param id
     * @param map
     * @return
     * @throws Exception
     */
    @RequestMapping("/getZiben")
    public String getZiben(String id, ModelMap map)throws Exception{
        Map<String ,Object> maps = new HashMap<String ,Object>();
        maps.put("id", id);
        PrincipalEx data = principalService.selectAppDetailLists(id);
        if(data==null){
            throw new MobException(MZchError.CONTENT_NOT_EXIST);
        }
        map.put("data", data);
     return BASE_PATH+"/zibenshare";
    }
    
    /**
     * 高校详情
     * @param id
     * @param map
     * @return
     * @throws Exception
     */
    @RequestMapping("/getColl")
    public String getColl(String id, ModelMap map)throws Exception{
        Map<String ,Object> maps = new HashMap<String ,Object>();
        maps.put("id", id);
        CollegemessageEx data = collegemessageService.selectAppDetailList(maps);
        if(data==null){
            throw new MobException(MZchError.CONTENT_NOT_EXIST);
        }
        map.put("data", data);
     return BASE_PATH+"/collshare";
    }
    
    /**
     * 技术供应详情
     * @param id
     * @param map
     * @return
     * @throws Exception
     */
    @RequestMapping("/getTec")
    public String getTec(String id, ModelMap map)throws Exception{
        Map<String ,Object> maps = new HashMap<String ,Object>();
        maps.put("id", id);
        TechnologymessageEx data = technologymessageService.selectDetail(maps);
        if(data==null){
            throw new MobException(MZchError.CONTENT_NOT_EXIST);
        }
        map.put("data", data);
     return BASE_PATH+"/tecshare";
    }
    
    /**
     * 技术需求详情
     * @param id
     * @param map
     * @return
     * @throws Exception
     */
    @RequestMapping("/getXq")
    public String getXq(String id, ModelMap map)throws Exception{
        Map<String ,Object> maps = new HashMap<String ,Object>();
        maps.put("id", id);
        XqmessageEx data = xqmessageService.selectAppDetailList(maps);
        if(data==null){
            throw new MobException(MZchError.CONTENT_NOT_EXIST);
        }
        map.put("data", data);
     return BASE_PATH+"/xqshare";
    }
    
    /**
     * 政策详情
     * @param id
     * @param map
     * @return
     * @throws Exception
     */
    @RequestMapping("/getPolicy")
    public String getPolicy(String id, ModelMap map)throws Exception{
        Map<String ,Object> maps = new HashMap<String ,Object>();
        maps.put("id", id);
        PolicyEx data = policyService.selectAppDetail(maps);
        if(data==null){
            throw new MobException(MZchError.CONTENT_NOT_EXIST);
        }
        map.put("data", data);
     return BASE_PATH+"/policyshare";
    }
    
    /**
     * 服务机构详情
     * @param id
     * @param map
     * @return
     * @throws Exception
     */
    @RequestMapping("/getSerOr")
    public String getSerOr(String id, ModelMap map)throws Exception{
        ServiceOrganizationExample example = new ServiceOrganizationExample();
        example.createCriteria().andIsAgreeEqualTo(1).andIdEqualTo(id);
        List<ServiceOrganization> list = serviceOrganizationService.selectByExample(example);
        ServiceOrganization data = list.get(0);
        if(data==null){
            throw new MobException(MZchError.CONTENT_NOT_EXIST);
        }
        map.put("data", data);
     return BASE_PATH+"/serOrshare";
    }
    
    /**
     * 银行金融详情
     * @param id
     * @param map
     * @return
     * @throws Exception
     */
    @RequestMapping("/getBank")
    public String getBank(String id, ModelMap map)throws Exception{
        BankExample example = new BankExample();
        example.createCriteria().andIsAgreeEqualTo(1).andIdEqualTo(id);
        List<Bank> list = bankService.selectByExample(example);
        Bank data = list.get(0);
        if(data==null){
            throw new MobException(MZchError.CONTENT_NOT_EXIST);
        }
        map.put("data", data);
     return BASE_PATH+"/bankshare";
    }
    
    /**
     * 项目申报详情
     * @param id
     * @param map
     * @return
     * @throws Exception
     */
    @RequestMapping("/getAppPro")
    public String getAppPro(String id, ModelMap map)throws Exception{
        ApplyProjectExample example = new ApplyProjectExample();
        example.createCriteria().andIsAgreeEqualTo(1).andIdEqualTo(id);
        List<ApplyProject> list =  applyProjectService.selectByExample(example);
        ApplyProject data = list.get(0);        
        if(data==null){
            throw new MobException(MZchError.CONTENT_NOT_EXIST);
        }
        data.setTime(DateUtil.dateToStr(data.getApplyEndTime()));
        map.put("data", data);
     return BASE_PATH+"/appProshare";
    }
    
    /**
     * 人才项目详情
     * @param id
     * @param map
     * @return
     * @throws Exception
     */
    @RequestMapping("/getRenCai")
    public String getRenCai(String id, ModelMap map)throws Exception{
        AbilityExample example = new AbilityExample();
        example.createCriteria().andIsAgreeEqualTo(1).andIdEqualTo(id);
        List<Ability> list = abilityService.selectByExample(example);
        Ability data = list.get(0);
        if(data==null){
            throw new MobException(MZchError.CONTENT_NOT_EXIST);
        }
        map.put("data", data);
     return BASE_PATH+"/renCaishare";
    }
    
    /**
     * 智库详情
     * @param id
     * @param map
     * @return
     * @throws Exception
     */
    @RequestMapping("/getZhiKu")
    public String getZhiKu(String id, ModelMap map)throws Exception{
        ZhikuEx data = zhikuService.selectDetailById(id);
        if(data==null){
            throw new MobException(MZchError.CONTENT_NOT_EXIST);
        }
        map.put("data", data);
     return BASE_PATH+"/zhiKushare";
    }
}

